#include <stdio.h>
#include <iostream>

struct Node
{
	int data;
	Node* next;
};

bool IsSingleListIntersect (Node* head1, Node* head2);
bool IsCircleListIntersect (Node* head1, Node* head2);

int main()
{

	system("pause");
	return 0;
}

bool IsSingleListIntersect (Node* head1, Node* head2)
{
	while (head1->next != NULL)
	{
		head1 = head1->next;
	}
	while (head2->next != NULL)
	{
		head2 = head2->next;
	}
	if (head1 == head2)
	{
		return true;
	}
	return false;
}

bool IsCircleListIntersect (Node* head1, Node* head2)
{
	Node* tempHead = head2;

	while(head1 != head2)
	{
		head2 = head2->next;
		if (head1 == tempHead)
		{
			return false;
		}
	}
	
	if (head1 == head2)
	{
		return true;
	}
	return true;
}